package br.fatec.ads.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import br.fatec.ads.dao.CandidaturaDAO;
import br.fatec.ads.dao.CandidaturaRespostaDAO;
import br.fatec.ads.exception.CandidaturaException;
import br.fatec.ads.exception.CandidaturaRespostaException;
import br.fatec.ads.exception.DataBaseException;
import br.fatec.ads.model.Candidatura;

public class CandidaturaConsultar extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public CandidaturaConsultar() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
			HttpSession session = request.getSession(false);
			
			List listaPergunta = new ArrayList();
			
			Candidatura candidatura = new Candidatura();
			CandidaturaDAO candidaturaDAO = CandidaturaDAO.getInstance();
			CandidaturaRespostaDAO candidaturaRespostaDAO = CandidaturaRespostaDAO.getInstance();
		
			candidatura = candidaturaDAO.getCandidatura(Integer.parseInt(request.getParameter("idCandidaturaConsultar")));
			
			listaPergunta = candidaturaRespostaDAO.listarCandidaturaRespostaPergunta(Integer.parseInt(request.getParameter("idCandidaturaConsultar")));
			
			session.setAttribute("candidatura", candidatura);
			session.setAttribute("listaPergunta", listaPergunta);
			 
			request.getRequestDispatcher("cadcandidatura_c.jsp").forward(request, response);
		} catch (CandidaturaException e) {
			e.printStackTrace();
		} catch (CandidaturaRespostaException e) {
			e.printStackTrace();
		} catch (DataBaseException e) {
			e.printStackTrace();
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}
}